/**
 */

package com.bei_en.common.util;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * @author Guocg
 *
 */
public class GenerateUtil {

	/**
	 * @author Guocg
	 * @param maxCode
	 *            YC2015080812345
	 * @return
	 */
	public static String geneCode(String maxCode) {

		String sub = maxCode.substring(10, maxCode.length());
		String head = maxCode.substring(0, 2);
		String date1 = maxCode.substring(2, 10);
		String date2 = DateUtil.currentTimestamp2String("yyyyMMdd");
		DecimalFormat format = new DecimalFormat("00000");
		int end;
		if (date1.equals(date2)) {
			end = Integer.valueOf(sub) + 1;
		} else {
			end = 1;
		}
		return head + date2 + format.format(end);
	}

	/**
	 * 生成订单代码，等等
	 * 
	 * @author Guocg
	 * @return
	 */
	public static String geneCode() {

		return UUID.randomUUID().toString().replace("-", "");
	}

	public static String geneDate() {

		return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
	}

	/**
	 * 生成订单代码，等等
	 * 
	 * @author Guocg
	 * @return
	 */
	public static String geneCaptcha() {

		Random random = new Random();
		int x = random.nextInt(899999);
		x = x + 100000;
		return x + "";
	}
}
